package api

import (
	"easyShop/model"
	"easyShop/services"
	"github.com/gin-gonic/gin"
)

type TestController struct {
}

func (t TestController) TestRotation(c *gin.Context) {
	for i := 0; i < 100000; i++ {
		go services.Rotation()
	}
}

func (t TestController) TestDatabaseSources(c *gin.Context) {
	dataCenterId, workerId := services.GetNextDataCenterIdAndWorkerId()
	workerDatabaseConfig := services.GetDatabaseConfigByDataCenterIdAndWorkerId(dataCenterId, workerId)
	conn, _ := services.GetConnectByDataCenterIdAndWorkerId(dataCenterId, workerId)
	var userInfo model.User
	conn.Model(model.User{}).Where("id = ?", 1).Find(&userInfo)
	c.JSON(200, gin.H{
		"code": 200,
		"data": gin.H{"config": workerDatabaseConfig, "userInfo": userInfo},
		"msg":  "uploaded",
	})
}
